
	$('#Commonheader').load('/pc/Commonheader.html');
	$('#Commonfooter').load('/pc/CommonFooter.html');
	
$(function(){

	
	$('#gzjg_main_price_ck').on('click','li',function(){
		$(this).addClass('active').siblings('.active').removeClass('active');
	})
	
	$('#gzjg_main_price_jg').on('click','li',function(){
		$(this).addClass('active').siblings('.active').removeClass('active');
		var data_jgnum = $(this).attr('data_jgnum');
		$('#gzjg_main_price_jgnum').find(`[data_jgnum = ${data_jgnum}]`).children().addClass('active');
		$('#gzjg_main_price_jgnum').find(`[data_jgnum = ${data_jgnum}]`).siblings().children('.active').removeClass('active');
	})
	
	//table内容向上滚动轮播
	var area =document.getElementById('scrollBox');
	var con1 = document.getElementById('con1');
	var con2 = document.getElementById('con2');
	con2.innerHTML=con1.innerHTML;
	function scrollUp(){
	    if(area.scrollTop>=con1.offsetHeight){
	        area.scrollTop=0;
	    }else{
	        area.scrollTop++
	    }
	}
	var time = 50;
	var mytimer=setInterval(scrollUp,time);
	area.onmouseover=function(){
	    clearInterval(mytimer);
	}
	area.onmouseout=function(){
	    mytimer=setInterval(scrollUp,time);
	}
	
	//ajax页面数据
	var zone = window.sessionStorage['zone'];//地区id
	var regDate = window.sessionStorage['regDate'];//上牌日期数据
	var mile = window.sessionStorage['mile'];//公里数
	var modelId = window.sessionStorage['modelId'];//车型id
	
	var modelName = window.sessionStorage['modelName'];//车型名称
	var year = window.sessionStorage['year'];//上牌日期
	var cityName = window.sessionStorage['cityName'];//城市名
	var gear_type = window.sessionStorage['gear_type'];//手动还是自动
	var liter = window.sessionStorage['liter'];//排量
	var discharge_standard = window.sessionStorage['discharge_standard'];//排放标准
	var model_price = window.sessionStorage['model_price'];//新车售价

	$('#modelName').html(modelName);
	$('#cityName').html(cityName);
	$('#year').html(year+'上牌');
	$('#miles').html(mile+'公里');
	$('#gear_type').html(gear_type);
	$('#liter').html('排量'+liter);
	$('#discharge_standard').html(discharge_standard);
	$('#model_price').html('新车售价：'+model_price);
	
	$.ajax({
		url:'/che300/estimatedValue',
		type:'get',
		data:{
			zone:zone,
			regDate:regDate,
			mile:mile,
			modelId:modelId
		},
		success:function(data){
			var normal = data.eval_prices[2];
			var good = data.eval_prices[1];
			var excellent = data.eval_prices[0];
			
			$('#gzjg_main_price_jgnum li:first-child>span').html(good.dealer_buy_price);
			$('#gzjg_main_price_jgnum li:nth-child(2)>span').html(good.individual_price);
			$('#gzjg_main_price_jgnum li:last-child>span').html(good.dealer_price);
			
			$('#gzjg_other_price span:first-child').html(good.dealer_low_buy_price);
			$('#gzjg_other_price span:nth-child(2)').html(good.individual_price);
			$('#gzjg_other_price span:nth-child(3)').html(good.dealer_low_sold_price);
			$('#gzjg_other_price span:last-child').html(good.dealer_high_sold_price);
			
			$('#gzjg_main_price_ck').on('click','li',function(e){
				e.stopPropagation();
				if( $(this).attr('id') == 'normal' ){
					$('#gzjg_main_price_jgnum li:first-child>span').html(normal.dealer_buy_price);
					$('#gzjg_main_price_jgnum li:nth-child(2)>span').html(normal.individual_price);
					$('#gzjg_main_price_jgnum li:last-child>span').html(normal.dealer_price);
					
					$('#gzjg_other_price span:first-child').html(normal.dealer_low_buy_price);
					$('#gzjg_other_price span:nth-child(2)').html(normal.individual_price);
					$('#gzjg_other_price span:nth-child(3)').html(normal.dealer_low_sold_price);
					$('#gzjg_other_price span:last-child').html(normal.dealer_high_sold_price);
				}
				if( $(this).attr('id') == 'good' ){
					$('#gzjg_main_price_jgnum li:first-child>span').html(good.dealer_buy_price);
					$('#gzjg_main_price_jgnum li:nth-child(2)>span').html(good.individual_price);
					$('#gzjg_main_price_jgnum li:last-child>span').html(good.dealer_price);
					
					$('#gzjg_other_price span:first-child').html(good.dealer_low_buy_price);
					$('#gzjg_other_price span:nth-child(2)').html(good.individual_price);
					$('#gzjg_other_price span:nth-child(3)').html(good.dealer_low_sold_price);
					$('#gzjg_other_price span:last-child').html(good.dealer_high_sold_price);
				}
				if( $(this).attr('id') == 'excellent' ){
					$('#gzjg_main_price_jgnum li:first-child>span').html(excellent.dealer_buy_price);
					$('#gzjg_main_price_jgnum li:nth-child(2)>span').html(excellent.individual_price);
					$('#gzjg_main_price_jgnum li:last-child>span').html(excellent.dealer_price);
					
					$('#gzjg_other_price span:first-child').html(excellent.dealer_low_buy_price);
					$('#gzjg_other_price span:nth-child(2)').html(excellent.individual_price);
					$('#gzjg_other_price span:nth-child(3)').html(excellent.dealer_low_sold_price);
					$('#gzjg_other_price span:last-child').html(excellent.dealer_high_sold_price);
				}
			})
			
			
		}
	})
	
	$('#ksgz_btn>p').click(function(e){
		e.stopPropagation();
    	var zone = $('#chooseCar_local>p').attr('cid');//城市id
    	var regDate = $('#chooseCar_year>p').attr('year')+'-'+$('#chooseCar_year>p').attr('mon');//日期
    	var mile = $('#mile').val();
    	var modelId = $('#chooseCar>p').attr('model_id');
    	
    	var modelName = $('#chooseCar>p').html();//车型全称
    	var year = $('#chooseCar_year>p').html();//上牌日期
    	var cityName = $('#chooseCar_city_list>li').html();//城市名
    	
    	var gear_type = $('#chooseCar>p').attr('gear_type');//手动还是自动
    	var liter = $('#chooseCar>p').attr('liter');//排量
    	var discharge_standard = $('#chooseCar>p').attr('discharge_standard');//排放标准
    	var model_price = $('#chooseCar>p').attr('model_price');//新车售价
    	
    	if($('#chooseCar>p').html() == '请选择车型' || $('#chooseCar_year>p').html() =='请选择年份' || $('#chooseCar_local>p').html() =='请选择地域'){
    		alert('信息不完整，请填写信息！');
    	}else{
    		$.ajax({
    			url:'/che300/estimatedValue',
    			type:'get',
    			data:{
    				zone:zone,
    				regDate:regDate,
    				mile:mile,
    				modelId:modelId
    			},
    			success:function(data){
    				
    				$('#modelName').html(modelName);
    		    	$('#cityName').html(cityName);
    		    	$('#year').html(year+'上牌');
    		    	$('#miles').html(mile+'公里');
    		    	$('#gear_type').html(gear_type);
    		    	$('#liter').html('排量'+liter);
    		    	$('#discharge_standard').html(discharge_standard);
    		    	$('#model_price').html('新车售价：'+model_price);
    		    	
    				var normal = data.eval_prices[2];
    				var good = data.eval_prices[1];
    				var excellent = data.eval_prices[0];
    				
    				$('#gzjg_main_price_jgnum li:first-child>span').html(good.dealer_buy_price);
    				$('#gzjg_main_price_jgnum li:nth-child(2)>span').html(good.individual_price);
    				$('#gzjg_main_price_jgnum li:last-child>span').html(good.dealer_price);
    				
    				$('#gzjg_other_price span:first-child').html(good.dealer_low_buy_price);
    				$('#gzjg_other_price span:nth-child(2)').html(good.individual_price);
    				$('#gzjg_other_price span:nth-child(3)').html(good.dealer_low_sold_price);
    				$('#gzjg_other_price span:last-child').html(good.dealer_high_sold_price);
    				
    				$('#gzjg_main_price_ck').on('click','li',function(e){
    					e.stopPropagation();
    					if( $(this).attr('id') == 'normal' ){
    						$('#gzjg_main_price_jgnum li:first-child>span').html(normal.dealer_buy_price);
    						$('#gzjg_main_price_jgnum li:nth-child(2)>span').html(normal.individual_price);
    						$('#gzjg_main_price_jgnum li:last-child>span').html(normal.dealer_price);
    						
    						$('#gzjg_other_price span:first-child').html(normal.dealer_low_buy_price);
    						$('#gzjg_other_price span:nth-child(2)').html(normal.individual_price);
    						$('#gzjg_other_price span:nth-child(3)').html(normal.dealer_low_sold_price);
    						$('#gzjg_other_price span:last-child').html(normal.dealer_high_sold_price);
    					}
    					if( $(this).attr('id') == 'good' ){
    						$('#gzjg_main_price_jgnum li:first-child>span').html(good.dealer_buy_price);
    						$('#gzjg_main_price_jgnum li:nth-child(2)>span').html(good.individual_price);
    						$('#gzjg_main_price_jgnum li:last-child>span').html(good.dealer_price);
    						
    						$('#gzjg_other_price span:first-child').html(good.dealer_low_buy_price);
    						$('#gzjg_other_price span:nth-child(2)').html(good.individual_price);
    						$('#gzjg_other_price span:nth-child(3)').html(good.dealer_low_sold_price);
    						$('#gzjg_other_price span:last-child').html(good.dealer_high_sold_price);
    					}
    					if( $(this).attr('id') == 'excellent' ){
    						$('#gzjg_main_price_jgnum li:first-child>span').html(excellent.dealer_buy_price);
    						$('#gzjg_main_price_jgnum li:nth-child(2)>span').html(excellent.individual_price);
    						$('#gzjg_main_price_jgnum li:last-child>span').html(excellent.dealer_price);
    						
    						$('#gzjg_other_price span:first-child').html(excellent.dealer_low_buy_price);
    						$('#gzjg_other_price span:nth-child(2)').html(excellent.individual_price);
    						$('#gzjg_other_price span:nth-child(3)').html(excellent.dealer_low_sold_price);
    						$('#gzjg_other_price span:last-child').html(excellent.dealer_high_sold_price);
    					}
    				})
    				
    				
    			}
    		})
    	}
	})
	
})